package com.yonyou.cloud.member.adapters.openapi.aop;

import com.yonyou.cloud.member.adapters.dto.ApiResponseDto;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Deprecated
// @Component
@Aspect
public class OpenApiResponseAspect {
    @Pointcut(value = "@annotation(io.swagger.annotations.ApiOperation)")
    public void openApis() {

    }

    @Around("openApis()")
    public ApiResponseDto openApiResponse(ProceedingJoinPoint jp) throws Throwable {
        Object result = jp.proceed(jp.getArgs());
        if (result instanceof Boolean) {
            return new ApiResponseDto((Boolean) result);
        } else {
            return new ApiResponseDto(true).setData(result);
        }
    }
}